﻿(function (angular) {
    'use strict';

    angular.module('Controllers', [])
        .controller('ProductsCtl', [
            '$scope', '$route', 'StoreRepository', function ($scope, $route, storeRepository) {

                var storeId = $route.current.params['storeId'];

                storeRepository.getStoreTitle(storeId).success(function (data) {
                    $scope.storeTitle = data;
                });

                storeRepository.getProductList(storeId).success(function(data) {
                    $scope.products = data;
                });
            }
        ])
        .controller('AppCtrl', [
            '$scope', 'StoreRepository', function ($scope, storeRepository) {
                
                $scope.setActiveLink = function ($event) {

                    var data = $event.currentTarget.dataset;
                    storeRepository.setApiUrl(data.apiUrl);
                }
            }
        ]);

})(window.angular);